package com.quentinbeauperin.twitbird
{
	import flash.display.Bitmap;
	import flash.display.Sprite;
	
	public class RingGenerator extends Sprite
	{
		public var ring:Bitmap;
		
		public var id:int;
		public var count:int = new int();
		public var randomY:int = new int();
		public var randomFrequency:int = new int();
		public var curentRingX:int = new int();
		
		public function RingGenerator(id:int):void
		{
			super();
			this.id = id;
		}
		
		// Create a ring
		public function createRing():void
		{
			if (count % randomFrequency == 0){			// Manage the frequency of appearance of the rings
				if (((800 + (count*8)) - curentRingX) > 150){    // Prevent having two rings too close
					if (id == 1){
						ring = new Assets.LeftRing();
					}
					else if (id == 2){
						ring = new Assets.RightRing();
					}
					addChild(ring);
					ring.x = 800 + (count*8);
					ring.y = randomY;
					curentRingX = ring.x;
				}
			}
		}
	}
}